import { createRouter, createWebHistory } from 'vue-router'

const routes = [
  {
    path: '/',
    name: 'Login',
    component: () => import('@/views/login/login.vue'),
  },
  {
    path: '/index',
    name: 'Index',
    component: () => import('@/views/index.vue'),
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/home.vue'),
        meta: {
          title: '首页',
          breadcrumb: ['首页']
        }
      },
      {
        path: '/user',
        name: 'User',
        redirect: '/user/list',
        meta: {
          title: '用户管理',
          breadcrumb: ['用户管理']
        },
        children: [
          {
            path: 'list',
            name: 'UserList',
            component: () => import('../views/userList.vue'),
            meta: {
              title: '用户列表',
              breadcrumb: ['用户管理', '用户列表']
            }
          }
        ]
      },
      {
        path: '/permission',
        name: 'Permission',
        redirect: '/permission/list',
        meta: {
          title: '权限管理',
          breadcrumb: ['权限管理']
        },
        children: [
          {
            path: 'list',
            name: 'PermissionList',
            component: () => import('../views/permissionList.vue'),
            meta: {
              title: '权限列表',
              breadcrumb: ['权限管理', '权限列表']
            }
          }
        ]
      }
    ]
  }
]

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes
})

export default router